//
//  L2Tab5.m
//  Lesson2
//
//  Created by Alexander Trifonov on 20.04.12.
//  Copyright (c) 2012 fgengine@gmail.com. All rights reserved.
//

#import "L2Tab5.h"

@implementation L2Tab5

- (void) viewDidLoad
{
    [super viewDidLoad];
    data = [[NSMutableArray arrayWithCapacity:32] retain];
}

- (void) viewDidUnload
{
    [data release];
    [super viewDidUnload];
}

- (IBAction) execute:(id)sender
{
    [data addObject:[NSString stringWithFormat:@"Row %d", [data count], nil]];
    [table reloadData];
}

- (NSInteger) numberOfSectionsInTableView:(UITableView*)tableView
{
    return 1;
}

- (NSInteger) tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
{
    return [data count];
}

- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:L2_TAB5_CELL];
    if(cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:L2_TAB5_CELL] autorelease];
    }
    cell.textLabel.text = [data objectAtIndex:indexPath.row];
    return cell;
}

@end
